home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / abomb6.zip / ABOMB.QC next >
Text File  |  1996-08-12  |  3KB  |  90 lines

  1. /*
  2.  code author status:
  3.  total: 26 lines by Nick & lot of lines by NoNixLNX2 ...
  4.  weapons.qc: 3 lines by Nick...
  5.  abom*.qc: 22 lines by Nick & rest by NoNixLNX2 ...
  6.  abomb.qc: 21 lines by Nick & rest by NoNixLNX2 ;)
  7.  (not including the following Spawn_ABomb documentation block)
  8. */
  9.  
  10. void() W_SetCurrentAmmo;
  11. void() ABomb_Explode;
  12.  
  13. /*
  14. ===========
  15. Spawn_ABomb
  16. ===========
  17. v0.03
  18. By Nick Wilson (nick-man@indra.com)
  19. v0.05b by NoNixLNX2 / tbittih@xgw.fi
  20. v0.06b by NoNixLNX2 / tbittih@xgw.fi
  21.  
  22. Creates an A-Bomb that hovers in the air.  It explodes, and
  23. kills everything.  It is set off after 30 seconds or if another player or
  24. monster touches it.  What fun!
  25. Uses:
  26. 50 shells  (½ of max)
  27. 100 nails  (½ of max)
  28. 50 cells   (½ of max) (id's BUG in items.qc: bound_other_ammo vs ammo_touch, bound_other_ammo limits to 100 but ammo_touch to 200?)
  29. 25 rockets (¼ of max)
  30. */
  31.  
  32. void() check_rand_16x = // sorry but had to do this... don't trust qcc ;)
  33. {
  34.     local float rnx1;
  35.     local float rnx2;
  36.     local float rnx3;
  37.     rnx3 = 4;
  38.     while (rnx3 > 0) //can you see we don't trust qcc/float roundings?
  39.     {
  40.         rnx2 = 4;
  41.         while (rnx2 > 0)
  42.         {
  43.             rnx1 = random();
  44.             if (!rnx1) bprint("Holy fsck! ");
  45.             bprint (ftos(rnx1)); bprint (" ");
  46.             rnx2 = rnx2 - 1;
  47.         }
  48.         bprint ("\n");
  49.         rnx3 = rnx3 - 1; // damn, where are the fsck-- and aargh++ ?
  50.     }
  51. /* results for 10 runs of this thingy: (does it round?)
  52.  *    0.0's:    6    1.0's:    8
  53.  *    added (16rand):    9.2 9.1 8.0 7.3 7.7 8.3 6.5 8.8 9.0 8.4
  54.  *    82.3/160 = 0.514375
  55.  *    can I trust that kind of random() function? maybe ;)
  56.  *    ... just don't use things like if (!random()) ...
  57.  */
  58. };
  59. void() Spawn_ABomb =
  60. {
  61. //    check_rand_16x();    //this test proves that 0.0 != 0 ... damn I wasted two hours on this ;)
  62.     local entity abomb;                //Create entity
  63. /* test-block */
  64.     if(self.ammo_shells < 50 || self.ammo_nails < 100 || self.ammo_rockets < 25 || self.ammo_cells < 50)
  65.         return;                    //Check for enough ammo
  66.     self.ammo_shells = self.ammo_shells - 50;    //Use up all
  67.     self.ammo_nails = self.ammo_nails - 100;    //the necessary
  68.     self.ammo_rockets = self.ammo_rockets - 25;    //ammo...
  69.     self.ammo_cells = self.ammo_cells - 50;
  70. /* end-of-test-block */
  71.     abomb = spawn();                //Spawn the abomb
  72.     abomb.owner = self;                //Who made who?
  73.     setorigin(abomb, self.origin + v_forward*16 + '0 0 24');    //above and in front
  74.     abomb.velocity = '0 0 0';            //Not goin anywhere
  75.     abomb.flags = FL_FLY;                //It flies
  76.     setmodel(abomb, "progs/grenade.mdl");        //It's a grenade
  77.     abomb.movetype = MOVETYPE_FLY;                //needed for spinning, MOVETYPE_NONE would be 'nuff if not spinning...
  78.     abomb.solid = SOLID_BBOX;                //It's solid... (trigger)
  79.     setsize(abomb, '0 0 0', '0 0 0');            //but you can walk through it...
  80.     abomb.touch = ABomb_Touch;                //If touched...
  81.     abomb.nextthink = time + 20;                //Or not...
  82.     abomb.think = ABomb_Count10;                //ka-BOOM!
  83.     abomb.effects=9; // EF_DIMLIGHT && BRIGHTFIELD
  84.     abomb.avelocity='400 300 200';                //spin
  85.     bprint(self.netname);                //Let everyone know...
  86.     bprint(" sets an A-Bomb\n");
  87.     lightstyle(0, "vutsrqponm");
  88.     W_SetCurrentAmmo();                //Set correct ammo
  89. };
  90.